package com.dt76.smallloanbackenduser.controller.zjs;

import com.dt76.smallloanbackenduser.remote.zjs.LebalRemote;
import com.dt76.smallloanbackenduser.utils.Page;
import com.dt76.smallloanbackenduser.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/zjs")
public class LebalController {

    @Autowired
    private LebalRemote lebalRemote;


    @RequestMapping("/qryPageLebal")

    public String qryPageAllPowerUser(Model model,
                                      @RequestParam(defaultValue = "1")Integer currentPageNo
                                     ) {



        if (currentPageNo<=0){
            currentPageNo=1;
        }


        Page page = lebalRemote.qryPageAllLebal(currentPageNo);
        //03.组织返回值
        model.addAttribute("queryLebalList", page.getRows());//用户列表
        model.addAttribute("page", page);
        //加入动态查询条件返回

        System.out.println(page.getRows());
        System.out.println(page);
        return "pages/zjs/userLable";
    }

    @RequestMapping("/delLebal/{userId}")
    @ResponseBody
    public Result delete(@PathVariable String userId){

        return lebalRemote.delLebal(Integer.parseInt(userId));
    }

    @RequestMapping("/udpLebal/{userId}")
    @ResponseBody
    public Result udpLable(@RequestParam String userId,
                           @RequestParam("lebal") String lebal){

        return lebalRemote.udpLebal(Integer.parseInt(userId),lebal);
    }




}
